home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1105 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How do you pass along a variable argument list?
  5. Date: 11 Jan 1996 14:37:32 GMT
  6. Organization: Computer People Inc.
  7. Message-ID: <ALUN.CHAMPION.96Jan11093732@g7240065.bridge.bst.bls.com>
  8. References: <4d1i8v$k8h@news.mcl.bdm.com> <4d30nv$k8r@tahko.lpr.carel.fi>
  9. NNTP-Posting-Host: bstfirewall.bst.bls.com
  10. In-reply-to: aril@cmt.lpr.mail.carel.fi's message of Thu, 11 Jan 1996 12:38:07
  11.     GMT
  12.  
  13. In article <4d30nv$k8r@tahko.lpr.carel.fi> aril@cmt.lpr.mail.carel.fi (Ari Lukumies) writes:
  14.  
  15. : ywu@plato.sky.bdm.com wrote:
  16.  
  17. :> I am writing a wrapper around a routine which takes variable argument list only. I  
  18. :> want my wrapper has the similar prototype and can pass the variable arguments  
  19. :> directly to the routine(by the way, I cannot change the code of that routine).
  20.  
  21. :> I guess it is really hard to do it in ANSI, and I know how to do it in a stupid  
  22. :> way---but, is there any way around??
  23.  
  24. : Actually, it's not so difficult. Here's an ANSI-compliant example that
  25. : wraps the printf function:
  26.  
  27. : #include    <stdio.h>
  28. : #include    <stdarg.h>
  29.  
  30. : void    MyPrintf(char *fmt, ...)
  31. : {
  32. :       va_list    argp;
  33.  
  34. :       va_start(argp, fmt);
  35. :       printf(fmt, argp);
  36.  
  37. Almost ANSI-compliant ;') This is meant to be vprintf()
  38.  
  39. :       va_end(argp);
  40. : }
  41.  
  42. Regards
  43.  
  44.    -A.
  45. -- 
  46. | A.Champion                |
  47.